<input type="hidden" name="parentId" value="<?php echo getParameter("parentId"); ?>" id="parentId"/>

    <script type="text/javascript">
        $("#fammn_categorylist").append($("#parentId"));

    </script>
<?php


if (!getParameter("parentId")) header("Location: ".createRelativeUrl("parentId","NULL"));

if (getParameter("operation")=="movepage"){
    $Param=getParameter("direction");
if ($Param=="Up" || $Param=="Down")    {
    $id=getParameter("objectid");
    $sSql="Select orderCmpnt  From ammn_category  Where id=".$id;
    $rs=$GLOBALS["conn"]->Execute($sSql);
    $OldOrder=$rs->fields["orderCmpnt"];
    $sign=">";
    $Order="ASC";
    if ($Param=="Up") {
        $Order="DESC"; $sign="<";
    }
    $sSql="Select id,orderCmpnt From ammn_category Where portalId = ".$_REQUEST["portalId"]." And id <> ".$id." And orderCmpnt ".$sign." ".$OldOrder."  Order By orderCmpnt  ".$Order;
   // echo $sSql."<br/>";
    $rs=$GLOBALS["conn"]->Execute($sSql);
    $NewId=$rs->fields["id"];
    $NewOrder=$rs->fields["orderCmpnt"];
    $sUpdateSql = "UPDATE ammn_category SET orderCmpnt=1000 WHERE id=".$id;
    if (EW_DEBUG_ENABLED) echo $sUpdateSql."<br/>";
    $GLOBALS["conn"]->Execute($sUpdateSql);
    $sUpdateSql = "UPDATE ammn_category SET orderCmpnt=".$OldOrder." WHERE id=".$NewId;
    if (EW_DEBUG_ENABLED) echo $sUpdateSql."<br/>";
    $GLOBALS["conn"]->Execute($sUpdateSql);
    $sUpdateSql = "UPDATE ammn_category SET orderCmpnt=". $NewOrder." WHERE id=".$id;
    if (EW_DEBUG_ENABLED) echo $sUpdateSql."<br/>";
    $GLOBALS["conn"]->Execute($sUpdateSql);
    $_REQUEST["direction"]="";
    //if (!EW_DEBUG_ENABLED) echo "<script>window.location='".ew_ScriptName()."?order=orderCmpnt&ordertype=ASC&parentId=".getParameter("parentId")."';</script>";
}}

/*
for($i=0;$i<40;$i++)
{

    echo "INSERT INTO `ammn_gallery` VALUES (NULL, ".(366+$i).", 'img_".(1+$i).".jpg', 'Y');<br/>";
}
*/
?>